import 'package:flutter/material.dart';
class Test23 extends StatefulWidget{
    _TestState createState() => _TestState();
}

class _TestState extends State<Test23> {
    
    IconData actionIcon = Icons.delete;

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
        appBar: AppBar(
            title: Text("按钮动画"),
            centerTitle: true,
            actions: <Widget>[
                AnimatedSwitcher(
                    transitionBuilder: (child,anim){
                        return ScaleTransition(
                            child: child,
                            scale:anim
                        );
                    },
                    duration: Duration(milliseconds: 300),
                    child: IconButton(
                        key: ValueKey(actionIcon),
                        icon: Icon(actionIcon),
                        onPressed: (){
                            setState(() {
                                if(actionIcon == Icons.delete){
                                    actionIcon = Icons.done;
                                }else{
                                   actionIcon = Icons.delete;
                                }
                            });
                        },
                    ),
                )
            ],
        ),
        body: Container(
            child: Text("按钮动画"),
        ),
        
    );
  }


}
